<?php
/**
 * Created by PhpStorm.
 * User: ����
 * Date: 2015/12/25
 * Time: 10:25
 */

namespace app\api\controllers;


use app\api\Response;
use app\models\GkyUser;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use app\common\utils\QyWechat;

class UserController extends Controller
{
    public function actionGetInfo($userid){

//        $options = array(
//            'token'=>'gky', //填写应用接口的Token
//            'encodingaeskey'=>'pRuLXJLJR2OGfFMhEDtzv7qXW9GMqX9YXdXoH5UocAx', //填写加密用的EncodingAESKey
//            'appid'=>'wx91d6852b806f2ab7', //填写高级调用功能的app id
//            'appsecret'=>'5H7VBRGGmX0B7FTwoMtNn2Fr3iYrcOWNlKofpYyrAdPZh1v85r4nBe6Ro7PCrUhN', //填写高级调用功能的密钥
//            'agentid'=>'1', //应用的id
//        );
//        $weObj = new QyWechat($options); //创建实例对象
//        $weObj->getUserInfo();

        $userInfo = GkyUser::findInfo($userid);
        Response::setHeader();
        echo json_encode(ArrayHelper::toArray($userInfo));
    }
    public function actionGetUsername(){
        $usernames=(new \yii\db\Query())
                ->select('id as value,name as text')
                ->from('gky_qyh_user')
                ->orderBy(['userId'=>SORT_ASC])
                ->all();
        Response::setHeader();
        echo json_encode($usernames);
    }
    public function actionTestMsg(){
        var_dump(\app\api\ApprovalMessage::sendMessage(557, 555, -1,'没事'));
    }

}
